//
//  GeneralButton.m
//  Medicine
//
//  Created by laber on 15/5/21.
//  Copyright (c) 2015年 laber. All rights reserved.
//

#import "GeneralButton.h"

@implementation GeneralButton

-(id)initwithImage:(NSString *)image title:(NSString *)title textFont:(CGFloat)font textColor:(UIColor *)color{
    if ([super init]) {
        _image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:image]];
        [self addSubview:_image];
        
        _text = [[UILabel alloc] init];
        _text.text = title;
        _text.font = [UIFont systemFontOfSize:font];
        _text.textColor = color;
        _text.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_text];
        
        [_image mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.mas_centerX);
            make.top.equalTo(self.mas_top);
        }];
        
        [_text mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.mas_centerX);
            make.top.equalTo(_image.mas_bottom).equalTo(@4);
        }];
    }
    return self;
}

@end
